package jvm.error;

import java.util.ArrayList;
import java.util.List;

/**
 * 98%的时间在GC,并且释放不足2%的堆内存
 * -Xms10m -Xmx10m -XX:+PrintGCDetails -XX:MaxDirectMemorySize=5m
 * @author jiangwz
 * @create 2019/9/17.
 */
public class GCOverheadDemo {

    public static void main(String[] args){
      int i = 0;
        List<String> list = new ArrayList<>();

        try {
            while (true) {
                list.add(String.valueOf(++i).intern());
            }
        }catch(Throwable e){
            System.out.println("************ "+i);
            e.printStackTrace();
            throw e;
        }
    }
}
